home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / ptv1n6.arc / CPUTYPE.ASM < prev    next >
Assembly Source File  |  1991-01-21  |  850b  |  41 lines

  1. ; Listing 1: cputype.asm
  2. ; Copyright (C) 1990 Nicholas Wilt.  All rights reserved.
  3.  
  4. .MODEL LARGE,C
  5.  
  6. .386
  7.  
  8. .CODE
  9.  
  10. ; cputype: function returns 0 if 8088 family,
  11. ;                1 if 80286 family,
  12. ;                2 if 80386 or better.
  13. ; No arguments.
  14. ; Returns value in AX.
  15.  
  16.     PUBLIC    cputype
  17.  
  18. cputype PROC
  19.     xor    dx,dx        ; Assume 8086 for now
  20.     push    dx        ; flags <- 0
  21.     popf            ;
  22.     pushf            ; Get flags back
  23.     pop    ax        ;
  24.     and    ax,0f000h    ; If the top 4 bits are set,
  25.     cmp    ax,0f000h    ;
  26.     je    quitcputype    ; return.  It's an 8086.
  27.     inc    dx        ; It's at least an 80286.
  28.     push    0F000h        ; flags <- 0F000h
  29.     popf            ;
  30.     pushf            ; Get flags back
  31.     pop    ax        ;
  32.     and    ax,0F000h    ; If the top 4 bits aren't set,
  33.     jz    quitcputype    ; it's an 80286
  34.     inc    dx        ; Otherwise it's a 386 or better
  35. quitcputype:
  36.     xchg    ax,dx        ; Return value in AX
  37.     ret            ; Return
  38. cputype ENDP
  39.  
  40.     END
  41.